 |
 |
 |
 |
#199601 - 04/01/03 10:53 PM
[6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Admin Emeritus
Registered: 11/29/01
Posts: 789
Loc: Des Moines, IA
|
* Updated September 15, 2005 ubbnews.php Modification and Redistribution of this code without perission is prohibited The Official Code can be found at http://www.ubbdev.com/ubb/ultimatebb.php/topic/33/42.html Reads the UBB for the latest topic in a forum, and displays a teaster of it on a page Required Parameter -- forum=## where ## is the forum number requested Optional Parameter -- threads=# where # is the number of threads to tease (5 limit) Optional Parameter -- surl=1 will turn on Spider Friendly URLs (Requires 6.7.x)Usage: just do an include with "http://yourdomain.com/path/ubbnews.php?forum=##&threads=X(&surl=1)" where ## is the number of the forum without any leading zeros and X is a number between 1 and 5. You will need to put your noncgi path in the script so it may read the vars_config.inc.php for your UBB paths. Download: UBBDev Requires: 6.4+ Features: - Counts your comments and puts the count next to the Comments Link - Comments Link will give them UBB Reply Screen - Read More takes them to the entire topic - Will display 1 topic of no threads=X is added to the URL - Feed multiple forums by doing multiple includes of the ubbnews.php - Will NOT feed private forums - Will display a message if your forum_##.threads file is missing - Author's name links to their profile - Spider Friendly URLs Known Issues: - Doesn't process Gramelins This can be corrected by placing ubbnews.php in your noncgi directory- Sometimes doesn't process URL's correctly (I've seen it on rare occasions, but bumping the Max Characters setting noted in the code should cure it) - You will receive a missing .threads error message after an upgrade. Rebuild your Forum Metadata on that forum to correct this error. This may/may not work on earlier versions, so use at your own risk. I put a hard limit of 5 in the PHP code to prevent the code from trying to tease every topic in the forum (Could kill performance). You can change this by editing if ($threads > 5)
$threads = 5;just change the 5 in both lines to whatever you want to cap it at. I honestly don't see a need to be over 10. Also, this may show a bit of lag if you have thousands of topic in the forums. I haven't tested this on large forums. August 26, 2005 NoticeUBBFeed was an unauthorized modification of the UBBNews code and I will provide NO support for UBBFeed, or my code contained in it. Posting here for support of UBBFeed will result in an unpleasant response.
_________________________
http://thegeeksinc.com [img]http://www.ubbdev.com/ud/?u=Sub_Zero&s=1[/img] points generated
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199635 - 09/20/03 12:07 AM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Master Hacker
Registered: 01/25/03
Posts: 3765
Loc: Saint Johns, PA
|
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199645 - 09/23/03 08:24 PM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Admin Emeritus
Registered: 11/29/01
Posts: 789
Loc: Des Moines, IA
|
Here's a patch to cure that and a missing .threads error Before $thread_data = file($threadspath); Add if (file_exists($threadspath)) {and After Insert } else {
$thr_array = 0;
echo "Unable to read .threads file. Either you are trying to access a private forum, or you need to Rebuild your forum stat files.";
}I'll upload a patched zip shortly.
_________________________
http://thegeeksinc.com [img]http://www.ubbdev.com/ud/?u=Sub_Zero&s=1[/img] points generated
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199670 - 10/02/03 10:32 PM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Admin Emeritus
Registered: 11/29/01
Posts: 789
Loc: Des Moines, IA
|
Doh! I forgot to commit the sort fix to the released version. I had it on my production version. I'll fix the zip. Patch: Find: $thr_data = array_reverse($thread_data); Replace with: $thr_data2 = array_reverse($thread_data);
array_pop($thr_data2);
sort($thr_data2);
$thr_data = array_reverse($thr_data2);
_________________________
http://thegeeksinc.com [img]http://www.ubbdev.com/ud/?u=Sub_Zero&s=1[/img] points generated
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199683 - 03/02/04 10:28 PM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Admin Emeritus
Registered: 11/29/01
Posts: 789
Loc: Des Moines, IA
|
I kind of got sidetracked on the ubbnews.php after a couple of major projects cropped up this past fall. I'm getting this back on my whiteboard to address/look into further.
A workaround for the graemlin problem is to drop ubbnews.php in the noncgi directory. I'll have to examine the Z lines a bit more to determine if I can do a replace on the graemlins, or somehow break it apart and insert in the noncgi url from the vars_config.inc.php.
Regarding the quote/code/list fix, I have a tempoary one, however, it doesn't handle multiple lists correctly. I'm going to rethink the code that I injected last fall into my beta version. I think I'm going need to do a string find and count, then compare the open and close counts and append the appropriate number of closing tags.
If you want, I can post my current temporary fix, but I'll need to do further testing on my boards after I write a more permenant fix. I have an idea about how to do a more permenant fix, I just need to code and test it on my boards before I release it. It's not going to break the UBB, I'd just rather break my beta directory than anyones live sites.
_________________________
http://thegeeksinc.com [img]http://www.ubbdev.com/ud/?u=Sub_Zero&s=1[/img] points generated
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199685 - 03/02/04 11:20 PM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Admin Emeritus
Registered: 11/29/01
Posts: 789
Loc: Des Moines, IA
|
I'm still alive.
I've been playing in Zend with the quote/code/list (Gotta love the Preview of the HTML and the ability to set breakpoints to examine varaible content). I did concept up a method of counting the open tags, and automatically closing the tags at the end of the teaser, regardless of where they are supposed to close. I'll probably be able to test that on a live board shortly.
The problem I'm running into on the gramelins is doing an outright replace on the img tags. If I append $NonCGIURL to all image tags, it would break any outside images in the feed. On the other hand, I cannot be guaranteed that I'm able to read /cgi-bin/vars_graemlins.cgi due to open_basedir restrictions. If I can be sure that I can read vars_graemlins, I can do some array work to "trim the fat" of the hash, and get it so I have just the graemlin image file names, and just do a search and replace on those file names. I could just include a base href, but would that break other parts of the page that it is feeding onto. That, I'm unsure of also.
_________________________
http://thegeeksinc.com [img]http://www.ubbdev.com/ud/?u=Sub_Zero&s=1[/img] points generated
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199693 - 03/17/04 01:25 PM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Member
Registered: 05/03/01
Posts: 57
|
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199696 - 03/18/04 02:41 AM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Member
Registered: 05/03/01
Posts: 57
|
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199702 - 03/21/04 05:49 PM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Master Hacker
Registered: 01/25/03
Posts: 3765
Loc: Saint Johns, PA
|
Sub, if you ever want to turn the times into a format that is adjusted via users preference, I wrote this js function that takes the normal 12-31-2004 08:42PM and turns it into something workable. <script language="Javascript" type="text/javascript">
<!--
function formatTime(input) {
var tippy = input;
var tippy_array = tippy.split("-");
var month = parseInt(tippy_array[0]) - 1;
var day = parseInt(tippy_array[1]) + 0;
if(tippy_array[2] != null && tippy_array[2] != '') {
var new_array_tippy = tippy_array[2].split(" ");
var year = parseInt(new_array_tippy[0]);
var newer_array_tippy = new_array_tippy[1].split(':');
hour = parseFloat(newer_array_tippy[0]);
if(new_array_tippy[2] == 'PM'){ hour += 12; }
var minutes = parseInt(newer_array_tippy[1]);
document.write('<span class="time">');
document.write(timestamp(new Date(year,month,day,hour,minutes,0), dfrm, null, 0, 0, 0, 0), "at ");
document.write(timestamp(new Date(year,month,day,hour,minutes,0), null, tfrm, 0, 0, 0, 0), '</span>');
}
}
//-->
</script>
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199704 - 03/22/04 10:27 AM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Admin Emeritus
Registered: 11/29/01
Posts: 789
Loc: Des Moines, IA
|
Originally posted by Ian Spence: I just don't see any reason why it's printing out the <html><body></body></html> and nothing else. I can't find anywhere in the code where it tells it to print that out If there is no query string found, it bugs out and outputs nothing. It seems that IE/Moz like to invent tags when none exist. I've PM'd Eric with a different (and less cluttered) method of fetching the query string to see if that cures the problem.
_________________________
http://thegeeksinc.com [img]http://www.ubbdev.com/ud/?u=Sub_Zero&s=1[/img] points generated
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199709 - 03/22/04 04:12 PM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Wizard
Registered: 01/10/00
Posts: 5354
Loc: Portland, OR, USA
|
Originally posted by Sub Zero:</font><hr /> So how do I determine what is a graemlin, and what is not without knowing what graemlins exist? <hr /></blockquote> <blockquote><font class="small">Originally posted by Ian Spence: [qb] work at it this way. IMG tags only allow full urls, and graemlins use relative paths. Do something like $message = pregreplace("/src="Graemlins//", "src="$NonCGIURL/Graemlins/", $message);That's untested, and should only work with custom graemlins. You could also try something like $message = pregreplace("/src="biggrin.gif/", "src="$NonCGIURL/biggrin.gif", $message);for each of the built in graemlins. [/qb]
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199740 - 08/23/05 08:39 AM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Member
Registered: 06/13/02
Posts: 100
|
OK, been playing around with this one, now the latest threads do not come up, but the threads with the latest posts. Code now looks like this, i have renamed it into ubbnews2.php: <?
// ubbnews2.php
// Reads the UBB for the latest topic in a forum, and displays a teaster of it on a page
// Required Paramater -- forum=## where ## is the forum number requested
// Optional Paramter -- threads=# where # is the number of threads to tease (5 limit)
$varspath = "<NonCGIPath>"; # Take this from the NonCGI Path setting in your cp.cgi
include("$varspath/vars_config.inc.php");
$forum = $_GET['forum'];
$threads = $_GET['threads'];
$threads = (isset($threads) && $threads) ? $threads : 1;
// If you dare, you can adjust the max number to tease by adjusting the number in the next 2 lines
// ******* WARNING - DO NOT REMOVE/COMMENT OUT THE CHECK! ********
if ($threads > 5)
$threads = 5;
if ($forum)
{
$ubbnewspath = $NonCGIPath . "/" . "Forum";
$threadspath = $ubbnewspath . $forum . "/" . "forum_" . $forum . ".threads";
if (file_exists($threadspath))
{
$thread_data = file($threadspath);
$thread_count = count($thread_data);
array_pop($thread_data);
array_pop($thread_data);
array_pop($thread_data);
array_pop($thread_data);
$thr_data2 = array_reverse($thread_data);
array_pop($thr_data2);
sort($thr_data2);
$thr_data = array_reverse($thr_data2);
$thr_start = 0;
$thr_array = $threads--;
$real_count = count($thr_data);
if ($real_count < $thr_array)
$thr_array = $real_count;
}
else
{
$thr_array = 0;
echo "Unable to read .threads file. Either you are trying to access a private forum, or you need to Rebuild your forum stat files.";
}
$count = 0;
$mereal_count = $real_count;
while($real_count)
{
$real_count--;
$extrame[$real_count] = "";
$extrameme = $extrame[$real_count];
$extrathisone = $thr_data[$real_count];
$extrameme= explode("!", $extrathisone);
$extrame[$real_count][0] = $extrameme[0];
$extrame[$real_count][1] = $extrameme[1];
$extrame[$real_count][2] = $extrameme[2];
$extrame[$real_count][3] = $extrameme[3];
$extrame[$real_count][4] = $extrameme[4];
}
while($real_count <= $mereal_count)
{
$extrame2[$real_count] = "!" . $extrame[$real_count][3] . "!" . " => " . "!" . $extrame[$real_count][1] . "!";
$real_count++;
}
rsort($extrame2);
$thr_data = $extrame2;
while ($count < $thr_array)
{
if ($count > 1)
echo "
";
$thisone = $thr_data[$thr_start];
$getme = explode("!", $thisone);
$getme2 = $getme[3];
$topicnum = trim($getme2);
$maxTextLenght=850;
$ubbnewspath = $NonCGIPath . "/" . "Forum";
$newsitem = $ubbnewspath . $forum . "/" . $topicnum . ".cgi";
$newsdetail = file($newsitem);
$num_lines = count ($newsdetail);
$comment_count = $num_lines - 2;
$aline = explode("||", $newsdetail[0]);
$zline = explode("||", $newsdetail[1]);
$author = $aline[8];
$authorid = $aline[9];
$authorurl = $NonCGIURL . "/ultimatebb.php?ubb=get_profile;u=" . $authorid;
$title = $aline[4];
$postdate = $zline[3];
$posttime = $zline[4];
$aspace=" ";
if(strlen($zline[6]) > $maxTextLenght )
{
$postdet = substr(trim($zline[6]),0,$maxTextLenght);
$postdet = substr($postdet,0,strlen($postdet)-strpos(strrev($postdet),$aspace));
$bot = strpos($postdet, "<blockquote>");
$bct = strpos($postdet, "</blockquote>");
if (($bot!==FALSE) and ($bct===FALSE))
{
$postdet = $postdet . "</blockquote>";
$nodots = "TRUE";
}
$lot = strpos($postdet, "<ul");
$lct = strpos($postdet, "</ul>");
if (($lot!==FALSE) and ($lct===FALSE))
{
$postdet = $postdet . "</ul>";
$nodots = "TRUE";
}
if ($nodots != "TRUE")
$postdet = $postdet . '...';
}
else
{
$postdet = $zline[6];
}
echo "<b>$title</b>
";
echo "<font size="1">";
print("Posted: $postdate $posttime by <a href="$authorurl">$author</a>");
echo "</font>
";
echo "
";
print($postdet);
$morepath = $NonCGIURL . "/ultimatebb.php?ubb=get_topic;f=" . $forum . ";t=" . $topicnum;
echo " ";
echo "<a href="$morepath">Read More...</a>";
echo "
";
$commentpath = $NonCGIURL . "/ultimatebb.php?ubb=reply;f=" . $forum . ";t=" . $topicnum;
echo "<a href="$commentpath">Comments ($comment_count)</a>
";
$count++;
$thr_start++;
}
}
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199744 - 09/09/05 01:18 AM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Wizard
Registered: 01/10/00
Posts: 5354
Loc: Portland, OR, USA
|
Well, I found a bug... I'm running the latest version and for once I'm using the section: if ($count > 1)
echo "
";(before I left it as "" and used something else, but now i'm going for a more professional look) What I'm seeing on my dev site is that the first entry ignores if ($count > 1)
echo "
";Which kind of sucks as I get parts that run together... Any ideas? This is the only thing that's holding development back right now (well, the only thing i need to worry about anyway); I've been coding up a storm lately... You can see examples of this error by looking at the "Headlines" section, the first two entries mesh together vs using: if ($count > 1)
echo " || ";And the "Tech News" section the first two stories mesh together instead of using: if ($count > 1)
echo "
";(Note that the headlines are generated from a file named "headlines.php" and news from "news.php" so they aren't in the same file)...
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#199749 - 09/12/05 12:07 PM
Re: [6.4 - 6.5 - 6.6 - 6.7] [beta] UBBNews PHP Feed
|
Admin Emeritus
Registered: 11/29/01
Posts: 789
Loc: Des Moines, IA
|
Zip File Updated. Fixes ====== - Fixed the Gizzy $count bug - Changed the include to require for vars_config.inc.php (Why try to run if you cannot fetch the paths  ) - Tweaked the internal code documentation - Cleaned up the formatting of the code for easier reading (I should have done this sooner) - Switched the URLs to Spider Friendly I'm going to mark this as a Finished Modification since it does seem rather stable.
_________________________
http://thegeeksinc.com [img]http://www.ubbdev.com/ud/?u=Sub_Zero&s=1[/img] points generated
|
|
Top
|
|
|
|
 |
 |
 |
 |
|
|